# Makefile for MININET project, to compile all object files and produce both
# the server and the client executables.
#
# Timothy Flynn(trflynn@wpi.edu)
# April 11, 2012

OBJ = Packet.o Frame.o common.o PhysicalLayer.o DataLinkLayer.o ApplicationLayer.o crc.o
LIB = -lpthread 

CFLAGS = -g -Wall

all: server.cpp client.cpp $(OBJ)
	g++ $(CFLAGS) server.cpp $(OBJ) -o server $(LIB)
	g++ $(CFLAGS) client.cpp $(OBJ) -o client $(LIB)

server: server.cpp $(OBJ)
	g++ $(CFLAGS) server.cpp $(OBJ) -o server $(LIB)

client: client.cpp $(OBJ)
	g++ $(CFLAGS) client.cpp $(OBJ) -o client $(LIB)

Packet.o: Packet.cpp Packet.h
	g++ $(CFLAGS) -c Packet.cpp

Frame.o: Frame.cpp Frame.h
	g++ $(CFLAGS) -c Frame.cpp

common.o: common.cpp common.h
	g++ $(CFLAGS) -c common.cpp

PhysicalLayer.o: PhysicalLayer.cpp PhysicalLayer.h
	g++ $(CFLAGS) -c PhysicalLayer.cpp

DataLinkLayer.o: DataLinkLayer.cpp DataLinkLayer.h
	g++ $(CFLAGS) -c DataLinkLayer.cpp
	
ApplicationLayer.o: ApplicationLayer.cpp ApplicationLayer.h
	g++ $(CFLAGS) -c ApplicationLayer.cpp

crc.o: crc.cpp crc.h
	g++ $(CFLAGS) -c crc.cpp

clean:
	rm -f server client *.o

